package com.pojoin.cms.util.criteria;

import java.util.Date;

/**
 * @author 糖醋鼻子
 * @date 2009.09.15
 * 操作符转换器，用于将单个规则转换成SQL字符串
 */
public class CriteriaCreator {
	private String key;
	
	public CriteriaCreator(String key) {
		this.key = key;
	}

	public String like(String value) {
		return "("+key+" like "+"'"+value+"'" +")";
	}

	public String moreThan(Long value)
	{
		return "("+key+" > "+value+")";
	}
	
	public String moreThan(Double value)
	{
		return "("+key+" > "+value+")";
	}
	
	public String moreThan(Date value)
	{
		return "("+key+" > '"+value.toString()+"')";
	}	
	
	public String lessThan(Long value)
	{
		return "("+key+" < "+value+")";
	}
	
	public String lessThan(Double value)
	{
		return "("+key+" < "+value+")";
	}
	
	public String lessThan(Date value)
	{
		return "("+key+" < '"+value.toString()+"')";
	}
	
	public String notLessThan(Long value)
	{
		return "("+key+" >= "+value+")";
	}
	
	public String notLessThan(Double value)
	{
		return "("+key+" >= "+value+")";
	}
	
	public String notLessThan(Date value)
	{
		return "("+key+" >= '"+value.toString()+"')";
	}
	
	public String notMoreThan(Long value)
	{
		return "("+key+" <= "+value+")";
	}
	
	public String notMoreThan(Double value)
	{
		return "("+key+" <= "+value+")";
	}
	
	public String notMoreThan(Date value)
	{
		return "("+key+" <= '"+value.toString()+"')";
	}	
	
	public String equals(Long value)
	{
		return "("+key+" = "+value+")";
	}
	
	public String equals(Double value)
	{
		return "("+key+" = "+value+")";
	}
	
	public String equals(Date value)
	{
		return "("+key+" = '"+value.toString()+"')";
	}	
	
	public String equals(String value)
	{
		return "("+key+" = '"+value.toString()+"')";
	}		
	
	public String notEquals(Long value)
	{
		return "("+key+" <> "+value+")";
	}
	
	public String notEquals(Double value)
	{
		return "("+key+" <> "+value+")";
	}
	
	public String notEquals(Date value)
	{
		return "("+key+" <> '"+value.toString()+"')";
	}	
	
	public String notEquals(String value)
	{
		return "("+key+" <> '"+value.toString()+"')";
	}		
}
